package Chapter2.Comparing.c8;

import java.io.*;

public class FileInputDemo2 {
    public static void main(String[] args) {
        try{
            FileInputStream fis = new FileInputStream("E:\\Test\\test1.txt");
            FileOutputStream fos= new FileOutputStream("E:\\Test\\test2.txt");
            BufferedInputStream bis = new BufferedInputStream(fis);
            BufferedOutputStream bos = new BufferedOutputStream(fos);
            //byte[] tmp = new byte[1024];
            int len;
            Long start = System.currentTimeMillis();
            while ((len=bis.read())!= -1) {
                bos.write(len);
            }
            bos.close();bis.close();
            long end = System.currentTimeMillis();
            System.out.println((end-start)/1000);
        }
        catch (FileNotFoundException e) {
            System.out.println(e.getMessage());
        }
        catch (IOException e) {
            e.printStackTrace();
        }
    }
}
